﻿Imports System.Data.SqlClient
Public Class frmRechParrai
  
    Private Sub txtPrix_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRech.TextChanged
        lstViwParrai.Items.Clear()
        Try
            If Not String.IsNullOrWhiteSpace(txtRech.Text) And Not String.IsNullOrEmpty(txtRech.Text) Then

                Dim enregi As String 'Récupère une ligne entier de la liste
                Dim t() As Integer 'stock les id des parain trouvé

                Dim i As Integer = 0 ' le nombre de case pour la table des parain trouvé
                For Each parrai In lstParrai
                    enregi = parrai.nom & " " & parrai.prenom & " " & _
                    parrai.tel & " " & parrai.adrss

                    If enregi.IndexOf(txtRech.Text, 0, enregi.Length, StringComparison.CurrentCultureIgnoreCase) > -1 Then
                        Dim Line As ListViewItem = New ListViewItem(New String() {parrai.idParai, parrai.nom, parrai.prenom, parrai.adrss})
                        lstViwParrai.Items.Add(Line)
                    End If
                Next
            End If
        Catch ex As Exception
            MsgBox("Une erreur c'est produite, veuillez informer l'administrateur de l'application !!!" & Environment.NewLine & "Déscription de l'erreur :" & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Erreur")
        End Try
    End Sub

    Private Sub frmRechParrai_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        frmMesParraines.Enabled = True
    End Sub

    Private Sub frmRechParrai_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            remplirLstParrai()
        Catch ex As Exception
            MsgBox("Une erreur c'est produite, veuillez informer l'administrateur de l'application !!!" & Environment.NewLine & "Déscription de l'erreur :" & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Erreur")
        End Try
    End Sub

    Private Sub lstViwParrai_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstViwParrai.DoubleClick
        Try
            idParrai = CInt(lstViwParrai.SelectedItems(0).SubItems(0).Text)
            For Each it As DictionaryEntry In frmMesParraines.cmbParrin.Items
                If it.Key = idParrai Then
                    frmMesParraines.cmbParrin.SelectedItem = it
                    idParrai = 0
                    Exit For
                End If
            Next
            Me.Close()
        Catch ex As Exception
            MsgBox("Une erreur c'est produite, veuillez informer l'administrateur de l'application !!!" & Environment.NewLine & "Déscription de l'erreur :" & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Erreur")
        End Try
    End Sub

End Class